package com.test.tinyurl.config.autoconfig;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.client.HttpServerErrorException;
import org.springframework.web.servlet.ModelAndView;

@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(HttpServerErrorException.class)
    public ModelAndView handleBusinessException(HttpServerErrorException e) throws Exception {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName(String.valueOf(e.getStatusCode().value()));
        return modelAndView;
    }
}
